<?php

//$con = new MongoClient('mongodb://localhost:27017');
$con = new MongoClient('mongodb://10.10.10.12:1026');
$db = $con->selectDB('test');
$collection = new MongoCollection($db, 'users');
$result = $collection->find();
$collection->insert([
    'username' => '李小龙',
    'password' => '李小龙'
]);
$collection2 = $db->selectCollection('cartoos');
$document = array( "title" => "Calvin and Hobbes", "author" => "Bill Watterson" );
$collection2->insert($document);

// 添加另一个文档，它的结构与之前的不同
$document = array( "title" => "XKCD", "online" => true );
$collection2->insert($document);

// 查询集合中的所有文档
$cursor = $collection2->find();

// 遍历查询结果
foreach ($cursor as $document) {
    echo $document["title"] . "\n";
}
